/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author anhvh_b00319
 */
@Entity
@Table(name = "Nutrition")
@NamedQueries({
    @NamedQuery(name = "Nutrition.findAll", query = "SELECT n FROM Nutrition n"),
    @NamedQuery(name = "Nutrition.findByNutritionID", query = "SELECT n FROM Nutrition n WHERE n.nutritionID = :nutritionID"),
    @NamedQuery(name = "Nutrition.findByNutritionName", query = "SELECT n FROM Nutrition n WHERE n.nutritionName = :nutritionName"),
    @NamedQuery(name = "Nutrition.findByNutritionDescription", query = "SELECT n FROM Nutrition n WHERE n.nutritionDescription = :nutritionDescription")})
public class Nutrition implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Nutrition_ID")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer nutritionID;
    @Basic(optional = false)
    @Column(name = "Nutrition_Name")
    private String nutritionName;
    @Basic(optional = false)
    @Column(name = "Nutrition_Description")
    private String nutritionDescription;

    public Nutrition() {
    }

    public Nutrition(Integer nutritionID) {
        this.nutritionID = nutritionID;
    }

    public Nutrition(Integer nutritionID, String nutritionName, String nutritionDescription) {
        this.nutritionID = nutritionID;
        this.nutritionName = nutritionName;
        this.nutritionDescription = nutritionDescription;
    }

    public Integer getNutritionID() {
        return nutritionID;
    }

    public void setNutritionID(Integer nutritionID) {
        Integer oldNutritionID = this.nutritionID;
        this.nutritionID = nutritionID;
        changeSupport.firePropertyChange("nutritionID", oldNutritionID, nutritionID);
    }

    public String getNutritionName() {
        return nutritionName;
    }

    public void setNutritionName(String nutritionName) {
        String oldNutritionName = this.nutritionName;
        this.nutritionName = nutritionName;
        changeSupport.firePropertyChange("nutritionName", oldNutritionName, nutritionName);
    }

    public String getNutritionDescription() {
        return nutritionDescription;
    }

    public void setNutritionDescription(String nutritionDescription) {
        String oldNutritionDescription = this.nutritionDescription;
        this.nutritionDescription = nutritionDescription;
        changeSupport.firePropertyChange("nutritionDescription", oldNutritionDescription, nutritionDescription);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nutritionID != null ? nutritionID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nutrition)) {
            return false;
        }
        Nutrition other = (Nutrition) object;
        if ((this.nutritionID == null && other.nutritionID != null) || (this.nutritionID != null && !this.nutritionID.equals(other.nutritionID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Nutrition[nutritionID=" + nutritionID + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
